package cn.dogger.easyboot.demo.controller;

import cn.dogger.easyboot.common.result.AjaxResult;
import cn.dogger.easyboot.redis.jedis.JedisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.params.SetParams;

/**
 * @author dogger
 * 2022/5/15 15:10
 */
@RestController
public class RedisController {
   private final Logger log;
    RedisController(){
        log = LoggerFactory.getLogger(getClass());
    }

    @GetMapping("/setlock")
    public AjaxResult setLock(){
        JedisUtils jedisUtils = new JedisUtils();
        String demooo = jedisUtils.setLock("demooo", SetParams.setParams().nx().px(JedisUtils.GET_LOCK_WAIT_TIME_OUT));
        log.info("setLock输出: ${}",demooo);
        return AjaxResult.success(demooo);
    }
}
